package com.gzyct.m.api.common.sign;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Component;

import com.gzyct.m.api.common.intf.req.InterfaceRequest;
import com.gzyct.m.api.common.intf.resp.InterfaceResp;

@Component
public class MD5Signer extends AbstractSigner {

	@Override
	protected String wrapRequestSignString(String signString, InterfaceRequest ir, String signKey)
			throws Exception {
		return signString + "&key=" + signKey;
	}

	@Override
	protected String wrapRespSignString(String signString, InterfaceResp ir, String signKey) throws Exception {
		return signString + "&key=" + signKey;
	}

	@Override
	protected String doSign(byte[] bytes) {
		return DigestUtils.md5Hex(bytes).toUpperCase();
	}

	@Override
	protected String wrapSignString(String signString, String channelCode, String signType, String signKey)
			throws Exception {
		return signString + "&key=" + signKey;
	}

}
